FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 5000
EXPOSE 5001

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["src/TerritoryGame.API/TerritoryGame.API.csproj", "src/TerritoryGame.API/"]
COPY ["src/TerritoryGame.Application/TerritoryGame.Application.csproj", "src/TerritoryGame.Application/"]
COPY ["src/TerritoryGame.Domain/TerritoryGame.Domain.csproj", "src/TerritoryGame.Domain/"]
COPY ["src/TerritoryGame.Infrastructure/TerritoryGame.Infrastructure.csproj", "src/TerritoryGame.Infrastructure/"]
RUN dotnet restore "src/TerritoryGame.API/TerritoryGame.API.csproj"
COPY . .
WORKDIR "/src/src/TerritoryGame.API"
RUN dotnet build "TerritoryGame.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "TerritoryGame.API.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TerritoryGame.API.dll"]
